package com.sniff.atp.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel
public class SniffResponse<T> {
    private T data;
    @ApiModelProperty(value = "返回码")
    private Integer code;
    @ApiModelProperty(value = "返回描述")
    private String msg;

    public SniffResponse() {
    }

    private SniffResponse(Integer code, String message, T data) {
        this.code = code;
        this.msg = message;
        this.data = data;
    }

    public static <T> SniffResponse<T> pass(T data) {
        return new SniffResponse<>(0, "成功", data);
    }

    public static <T> SniffResponse<T> fail(String msg, T data) {
        return new SniffResponse<>(10000, msg, data);
    }

    public static <T> SniffResponse<T> fail(Integer code, String msg) {
        return new SniffResponse<>(code, msg, null);
    }
}
